﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sasc.PV.DAL;
using Sasc.PV.BLL;

namespace Sasc.PV.Web.Admin.SystemManage
{
    public partial class DanWeiInfo : PVAdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ERPDanWeiInfo MyDanWei = new ERPDanWeiInfo();
                ERPDanWeiInfo info = MyDanWei.GetModel();

                TextBox1.Text = info.DanWeiName;
                TextBox2.Text = info.Tel;
                TextBox3.Text = info.Fax;
                TextBox4.Text = info.YouBian;
                TextBox5.Text = info.Address;
                TextBox6.Text = info.WebUrl;
                TextBox7.Text = info.Email;
                TextBox8.Text = info.KaiHuHang;
                TextBox9.Text = info.ZhangHao;
                ViewState["ID"] = info.ID.ToString();
                //设定按钮权限
                ImageButton1.Visible = PublicMethod.StrIFIn("|084M|", PublicMethod.GetSessionValue("QuanXian"));

                //判断是否属于查询模块
                try
                {
                    string SerchTypeStr = Request.QueryString["Type"].ToString();
                    this.ImageButton1.Visible = false;
                }
                catch
                { }
            }


        }

        //修改
        protected void SubmitImageButton_Click(object sender, ImageClickEventArgs e)
        {
            ERPDanWeiInfo MyDanWei = new ERPDanWeiInfo();
            MyDanWei.DanWeiName = TextBox1.Text.Trim();
            MyDanWei.Tel = TextBox2.Text.Trim();
            MyDanWei.Fax = TextBox3.Text;
            MyDanWei.YouBian = TextBox4.Text;
            MyDanWei.Address = TextBox5.Text;
            MyDanWei.WebUrl = TextBox6.Text;
            MyDanWei.Email = TextBox7.Text;
            MyDanWei.KaiHuHang = TextBox8.Text;
            MyDanWei.ZhangHao = TextBox9.Text;
            MyDanWei.ID = Convert.ToInt32(ViewState["ID"]);
            MyDanWei.Update(MyDanWei);

            WriteRiZhi("用户修改单位信息");
            MessageBox.ShowAndRedirect(this, "单位信息修改成功！", "DanWeiInfo");

        }
    }
}